<?php
/**
 * 애드페이 (AD-Pay for Gnuboard4)
 *
 * Copyright (c) 2010 Choi Jae-Young <www.miwit.com>
 *
 * 저작권 안내
 * - 저작권자는 이 프로그램을 사용하므로서 발생하는 모든 문제에 대하여 책임을 지지 않습니다. 
 * - 이 프로그램을 어떠한 형태로든 재배포 및 공개하는 것을 허락하지 않습니다.
 * - 이 저작권 표시사항을 저작권자를 제외한 그 누구도 수정할 수 없습니다.
 */

include_once("_common.php");
include_once("_config.php");
include_once("_lib.php");

$pr = array();

if ($pr_id && $w == "u")
{
    $is_modify = "";
    $sql = "select * from $pb[order_table] where pr_id = '$pr_id' and or_app = '1' and or_edate >= '$g4[time_ymd]'";
    $row = sql_fetch($sql);
    if ($row)
        $is_modify = "disabled";

    $sql = "select * from $pb[product_table] where pr_id = '$pr_id'";
    $row = sql_fetch($sql);

    if (!$row)
        alert("자료가 없습니다.");

    $pr = $row;

}

if (!$row[pr_cash]) $row[pr_cash] = 0;
if (!$row[pr_point]) $row[pr_point] = 0;
if (!$row[pr_target]) $row[pr_target] = "_blank";


$g4[title] = "애드페이 상품관리";
include_once("adm-head.php");
?>

<link rel="stylesheet" href="style.css" type="text/css"/>
<style type="text/css">
.tdh { width:120px; }
.tdb { text-align:left; padding:0 0 0 10px; }
.tdb .tip { font-size:11px; color:#888; }
</style>

<h3> <img src="img/miwit.gif" align="absmiddle"> <?=$g4[title]?> </h3>
<form name="fconfig" method="post" action="adm-banner-update.php" enctype="multipart/form-data">
<input type="hidden" name="w" value="<?=$w?>"/>
<input type="hidden" name="pr_id" value="<?=$pr[pr_id]?>"/>

<? if ($is_modify) echo "<div>※ 이 상품으로 진행중인 광고가 있어 일부항목 수정 및 삭제가 불가합니다.</div>"; ?>
<table class="content" width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#cccccc">
<tr>
    <td class="tdh"> <div>배너코드</div> </td>
    <td class="tdb">
        <input type="text" name="pr_code" size="10" maxlength="10" required alphanumericunderline itemname="배너코드" value="<?=$row[pr_code]?>" class="ed" <?=$is_modify?>>
        <span class="tip"> (배너삽입 코드에 사용될 배너 고유번호)
            <? if ($w=="u") echo " 사용방법 : ".htmlspecialchars('<?=mw_pay_banner("'.$row[pr_code].'", "스킨")?>'); ?> </span>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>배너이름</div> </td>
    <td class="tdb">
        <input type="text" name="pr_name" size="20" maxlength="20" required itemname="배너이름" value="<?=$row[pr_name]?>" class="ed">
    </td>
</tr>
<tr>
    <td class="tdh"> <div>사용여부</div> </td>
    <td class="tdb">
        <input type="checkbox" name="pr_app" value="1"> 사용
        <script type="text/javascript"> fconfig.pr_app.checked = "<?=$row[pr_app]?>"; </script>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>배너종류</div> </td>
    <td class="tdb">
        <select name="pr_type" required itemname="배너종류" <?=$is_modify?>>
        <option value=""> </option>
        <option value="i"> 이미지 배너 </option>
        <option value="t"> 텍스트 배너 </option>
        <script type="text/javascript"> fconfig.pr_type.value = "<?=$row[pr_type]?>"; </script>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>노출기간</div> </td>
    <td class="tdb">
        <input type="text" name="pr_period" size="10" maxlength="10" numeric required itemname="노출기간" value="<?=$row[pr_period]?>" class="ed"> 일
    </td>
</tr>
<tr>
    <td class="tdh"> <div>최대등록갯수</div> </td>
    <td class="tdb">
        <input type="text" name="pr_reg_count" size="10" maxlength="10" numeric required itemname="최대등록갯수" value="<?=$row[pr_reg_count]?>" class="ed"> 개
    </td>
</tr>
<tr>
    <td class="tdh"> <div>배너크기</div> </td>
    <td class="tdb">
        <input type="text" name="pr_width" size="10" maxlength="5" numeric itemname="배너가로크기" value="<?=$row[pr_width]?>" class="ed"> px × 
        <input type="text" name="pr_height" size="10" maxlength="5" numeric itemname="배너세로크기" value="<?=$row[pr_height]?>" class="ed"> px
        <span class="tip"> (가로×세로, 이미지 배너의 경우) </span>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>출력순서</div> </td>
    <td class="tdb">
        <select name="pr_order" id="pr_order" required itemname="출력순서">
            <option value="rand">랜덤출력</option>
            <option value="date">등록일 오름차순</option>
            <option value="date_desc">등록일 내림차순</option>
            <option value="edate">마감일 오름차순</option>
            <option value="edate_desc">마감일 내림차순</option>
        </select>
        <script> fconfig.pr_order.value = "<?=$row['pr_order']?>"; </script>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>포인트</div> </td>
    <td class="tdb">
        <input type="text" name="pr_point" size="10" maxlength="10" itemname="포인트" value="<?=$row[pr_point]?>" class="ed"> 점
    </td>
</tr>
<tr>
    <td class="tdh"> <div><?=$mw_cash[cf_cash_name]?></div> </td>
    <td class="tdb">
        <input type="text" name="pr_cash" size="10" maxlength="10" itemname="<?=$mw_cash[cf_cash_name]?>" value="<?=$row[pr_cash]?>" class="ed">
        <?=$mw_cash[cf_cash_unit]?>
        <? if (!$mw_cash[cf_cash_name]) echo "(<a href='http://g4.miwit.com/bbs/board.php?bo_table=g4_family' target='_blank'>설치안됨, 컨텐츠샵 다운받기</a>)"; ?>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>적립 포인트</div> </td>
    <td class="tdb">
        <input type="text" name="pr_member_point" size="10" maxlength="10" itemname="포인트" value="<?=$row[pr_member_point]?>" class="ed"> 점
        <span class="tip"> (클릭한 회원에게 적립하는 포인트) </span>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>기본 배너</div> </td>
    <td class="tdb">
        <? if ($row[pr_default_file])
            echo "<div style='padding:10px 0 10px 10px;'>".mw_pay_banner_view($row[pr_default_file], "", $row[pr_width], $row[pr_height])."</div>"; ?>
        <input type="file" name="pr_default_file" size="50" itemname="기본 배너" class="ed">
        <? if ($row[pr_default_file]) echo "<input type='checkbox' name='pr_default_del' value='1'> 삭제"; ?>
        <span class="tip"> (등록된 배너가 없을 경우 출력될 배너) </span>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>기본 URL</div> </td>
    <td class="tdb">
        <input type="text" name="pr_default_url" size="50" itemname="기본 URL" value="<?=$row[pr_default_url]?>" class="ed">
    </td>
</tr>
<tr>
    <td class="tdh"> <div>기본타겟</div> </td>
    <td class="tdb">
        <select name="pr_target" required itemname="기본타겟">
        <option value=""> </option>
        <option value="_blank"> 새창 </option>
        <option value="_self"> 현재 </option>
        <option value="_top"> 전체 </option>
        <script type="text/javascript"> fconfig.pr_target.value = "<?=$row[pr_target]?>"; </script>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>기본 광고코드</div> </td>
    <td class="tdb">
        <textarea name="pr_default_code" id="pr_default_code" rows="5" cols="50" itemname="광고코드"><?=$row['pr_default_code']?></textarea>
        <div class="tip"> 애드센스 등의 광고코드 입력용 </div>    </td>
    </td>
</tr>
</table>

<p align="center" style="margin-top:30px;">
    <input type="submit" value="확     인" class="btn1">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" value="목     록" class="btn1" onclick="location.href='adm-banner.php'">
</p>

</form>

<?
include_once("adm-tail.php");
